package com.github.lee.unsplash.utils.ba

import android.graphics.drawable.Drawable
import android.view.View
import androidx.appcompat.widget.Toolbar
import androidx.databinding.BindingAdapter


@BindingAdapter(
    value = [
        "navigation_icon", "navigation_click"
    ], requireAll = false
)
fun toolbarNavigation(v: Toolbar, icon: Drawable?, clickBlock: ((View) -> Unit)?) {
    if (null != icon) {
        v.navigationIcon = icon
    }
    if (null != clickBlock) {
        v.setNavigationOnClickListener {
            clickBlock.invoke(it)
        }
    }
}